<form id="component-form-step-1" class="layui-form" action="" lay-filter="component-form-step-1">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">产品名称</label>
            <div class="layui-input-inline">
                <input type="text" name="title" required  lay-verify="required" placeholder="请输入产品名称" autocomplete="off" class="layui-input" v-model="title">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">名称颜色</label>
            <div class="layui-input-inline">
                <input type="text" name="title_color" required  lay-verify="required" placeholder="示例：#ffffff" autocomplete="off" class="layui-input" v-model="title_color">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">产品型号</label>
            <div class="layui-input-inline">
                <input type="text" name="model" required  lay-verify="required" placeholder="请输入产品供应商型号" autocomplete="off" class="layui-input" v-model="model">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">产品品牌</label>
            <div class="layui-input-inline">
                <select name="brand_id" lay-verify="required" lay-search="" lay-filter="brand_id">
                    <option value="">请求选择品牌</option>
                    {volist name="commParam['brand']" id="brand"}
                    <option value="{$brand['id']}">{$brand['name']}</option>
                    {/volist}
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">产品类型</label>
        <div class="layui-input-block">
            <div class="layui-inline">
                <select id="category1" name="category1" lay-verify="required" lay-search="" lay-filter="category1">
                    <option value="">请选择一级分类</option>
                    {volist name="commParam['category']" id="category"}
                    <option value="{$category['id']}">{$category['name']}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-inline">
                <select id="category2" name="category2" lay-verify="required" lay-search="" lay-filter="category2">
                    <option value="">请选择二级分类</option>
                </select>
            </div>
            <div class="layui-inline">
                <select id="category3" name="category3" lay-verify="required" lay-search="" lay-filter="category3">
                    <option value="">请选择三级分类</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">产品库存</label>
            <div class="layui-input-inline">
                <input type="number" name="inventory" required  lay-verify="required" placeholder="请输入产品库存" autocomplete="off" class="layui-input" v-model="inventory">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">库存名称</label>
            <div class="layui-input-inline">
                <input type="text" name="inventory_unit" required  lay-verify="required" placeholder="示例：步，台" autocomplete="off" class="layui-input" v-model="inventory_unit">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">产品原价</label>
            <div class="layui-input-inline">
                <input type="number" name="original_price" required  lay-verify="required" placeholder="请输入产品原价" autocomplete="off" class="layui-input" v-model="original_price">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">最低原价</label>
            <div class="layui-input-inline">
                <input type="number" name="min_original_price" required  lay-verify="required" placeholder="请输入最低原价" autocomplete="off" class="layui-input" v-model="min_original_price">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">最大原价</label>
            <div class="layui-input-inline">
                <input type="number" name="max_original_price" required  lay-verify="required" placeholder="请输入最大原价" autocomplete="off" class="layui-input" v-model="max_original_price">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">产品售价</label>
            <div class="layui-input-inline">
                <input type="number" name="price" required  lay-verify="required" placeholder="请输入产品售价" autocomplete="off" class="layui-input" v-model="price">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">最低售价</label>
            <div class="layui-input-inline">
                <input type="number" name="min_price" required  lay-verify="required" placeholder="请输入最低售价" autocomplete="off" class="layui-input" v-model="min_price">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">最大售价</label>
            <div class="layui-input-inline">
                <input type="number" name="max_price" required  lay-verify="required" placeholder="请输入最大售价" autocomplete="off" class="layui-input" v-model="max_price">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">赠送积分</label>
            <div class="layui-input-inline">
                <input type="number" name="give_integral" required  lay-verify="required" placeholder="请输入购买赠送积分" autocomplete="off" class="layui-input" v-model="give_integral">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">最低起购</label>
            <div class="layui-input-inline">
                <input type="number" name="buy_min_number" required  lay-verify="required" placeholder="请输入最低起购" autocomplete="off" class="layui-input" v-model="buy_min_number">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">最大起购</label>
            <div class="layui-input-inline">
                <input type="number" name="buy_max_number" required  lay-verify="required" placeholder="请输入最大起购" autocomplete="off" class="layui-input" v-model="buy_max_number">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">销量</label>
            <div class="layui-input-inline">
                <input type="number" name="sales_count" required  lay-verify="required" placeholder="请输入销量" autocomplete="off" class="layui-input" v-model="sales_count">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">访问次数</label>
            <div class="layui-input-inline">
                <input type="number" name="access_count" required  lay-verify="required" placeholder="请输入访问次数" autocomplete="off" class="layui-input" v-model="access_count">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">视频地址</label>
        <div class="layui-input-inline">
            <input type="text" name="video" required  lay-verify="required" placeholder="请输入短视频地址" autocomplete="off" class="layui-input" v-model="video">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">扣减库存</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_deduction_inventory" lay-skin="switch" lay-filter="is_deduction_inventory" value="1">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否上架</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_shelves" lay-skin="switch" lay-filter="is_shelves" value="1">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否删除</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_delete_time" lay-skin="switch" lay-filter="is_delete_time" value="1">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">首页图片</label>
            <button type="button" class="layui-btn" id="home_recommended_images">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">首页推荐</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_home_recommended" lay-skin="switch" lay-filter="is_home_recommended" value="1">
            </div>
        </div>
    </div>
    <div class="layui-form-item" v-cloak v-if="!!home_recommended_images">
        <label class="layui-form-label">首图预览</label>
        <div class="layui-input-inline">
            <img :src="home_recommended_images" width="200" height="200">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">封面图片</label>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn" id="images">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>
    </div>
    <div class="layui-form-item" v-cloak v-if="!!images">
        <label class="layui-form-label">封面预览</label>
        <div class="layui-input-inline">
            <img :src="images" width="200" height="200">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">产品主图</label>
            <button type="button" class="layui-btn" id="image-upload">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">图片数量</label>
            <div class="layui-input-inline">
                <input type="number" name="photo_count" required  lay-verify="required" placeholder="请输入产品名称" autocomplete="off" class="layui-input" v-model="photo_count">
            </div>
        </div>
    </div>
    <div class="layui-form-item" v-cloak v-show="product_images.length > 0">
        <label class="layui-form-label">主图预览</label>
        <div class="layui-col-md8" id="image-preview">
            <!--http://img.fygift.com//2016/3/2396053567978906704.jpg-->
            <div class="layui-inline" v-for="(image,i) in product_images">
                <img :src="image" width="200" height="200">
                <input type="hidden" name="product_images[]" :value="image">
                <p style="text-align: center;">
                    <button class="layui-btn layui-btn-sm layui-btn-danger" @click.stop.prevent="delImage(i)"><i class="layui-icon">&#xe640; 删除</i></button>
                </p>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">产品属性</label>
        <button type="button" class="layui-btn" @click.stop.prevent="addAttr">
            <i class="layui-icon">&#xe608;</i>添加属性
        </button>
    </div>
    <div class="layui-form-item" v-cloak v-show="attr_list.length > 0">
        <label class="layui-form-label">属性列表</label>
        <div class="layui-col-md8">
            <table class="layui-table">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>属性名称</th>
                    <th>属性值</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(attr,i) in attr_list">
                    <td>{{i+1}}</td>
                    <td>
                        <input type="text" v-model="attr.attrName" placeholder="请输入属性名称" autocomplete="off" class="layui-input">
                    </td>
                    <td>
                        <input type="text" v-model="attr.attrValue" placeholder="请输入属性值" autocomplete="off" class="layui-input">
                    </td>
                    <td>
                        <button class="layui-btn layui-btn-xs" @click.stop.prevent="delAttr(i)"><i class="layui-icon">&#xe640; 删除</i></button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">产品地区</label>
            <button type="button" class="layui-btn">
                <i class="layui-icon">&#xe608;</i>添加地区
            </button>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否支持</label>
            <div class="layui-input-block">
                <input type="checkbox" name="region_type" lay-skin="switch" lay-filter="region_type" value="1">
            </div>
        </div>
    </div>
    <div class="layui-form-item" v-cloak v-show="region_list.length > 0">

    </div>
    <!--<div class="layui-form-item">-->
    <!--<div class="layui-input-block">-->
    <!--<button class="layui-btn" lay-submit lay-filter="add_step1">下一步</button>-->
    <!--</div>-->
    <!--</div>-->
</form>

<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use(['upload','form'], function(){
        var upload = layui.upload;
        var $ = layui.jquery;
        var form = layui.form;
        // var add_step1 = {};

        // 初始化一个VUE对象
        var add_step1 = new Vue({
            'el' : '#component-form-step-1',
            'data' : {
                title : '',
                title_color : '',
                inventory : '',
                inventory_unit : '',
                brand_id : '',
                brand_name : '',
                category1 : '',
                category1_name : '',
                category2 : '',
                category2_name : '',
                category3 : '',
                category3_name : '',
                product_images : [],
                model : '',
                images : '',
                original_price : '',
                min_original_price : '0.00',
                max_original_price : '0.00',
                price : '',
                min_price : '0.00',
                max_price : '0.00',
                give_integral : '0',
                buy_min_number : '1',
                buy_max_number : '0',
                is_deduction_inventory : '',
                is_shelves : '',
                is_home_recommended : '',
                photo_count : '0',
                attr_list : [],
                region_type : '',
                region_list : [],
                home_recommended_images : '',
                sales_count : '0',
                access_count : '0',
                video : '',
                is_delete_time : ''
            },
            methods : {
                addAttr : function () {
                    var self = this;
                    self.attr_list.push({
                        attrName : '',
                        attrValue : ''
                    });
                },
                delAttr : function (i) {
                    var self = this;
                    self.attr_list.splice(i,1);
                },
                delImage : function (i) {
                    var self = this;
                    self.product_images.splice(i,1);
                }
            },
            watch : {
                brand_id : function (newVal,oldVal) {
                    var self = this;
                    form.val("component-form-step-1", {
                        brand_id : newVal
                    });
                    for(var k in commParam['brand']){
                        if(commParam['brand'][k]['id'] == newVal){
                            self.brand_name = commParam['brand'][k]['name'];
                            break;
                        }
                    }
                },
                region_type : function (newVal,oldVal) {
                    var self = this;
                    form.val("component-form-step-1", {
                        region_type : newVal==1
                    });
                },
                is_deduction_inventory : function (newVal,oldVal) {
                    var self = this;
                    // console.log('trigger is_deduction_inventory');
                    // if(newVal == 1){
                    //     // 模拟选中事件
                    //     $('input[name="is_deduction_inventory"]').next('div[lay-skin="_switch"]').click();
                    // }
                    form.val("component-form-step-1", {
                        is_deduction_inventory : newVal==1
                    });
                },
                is_shelves : function (newVal,oldVal) {
                    var self = this;
                    form.val("component-form-step-1", {
                        is_shelves : newVal==1
                    });
                },
                is_home_recommended : function (newVal,oldVal) {
                    var self = this;
                    form.val("component-form-step-1", {
                        is_home_recommended : newVal==1
                    });
                },
                is_delete_time : function (newVal,oldVal) {
                    var self = this;
                    form.val("component-form-step-1", {
                        is_delete_time : newVal>0
                    });
                },
                category1 : function (newVal,oldVal) {
                    // 模拟选中事件
                    $('select[name="category1"]').next().find('.layui-anim').children('dd[lay-value="'+newVal+'"]').click();
                },
                category2 : function (newVal,oldVal) {
                    // 模拟选中事件
                    $('select[name="category2"]').next().find('.layui-anim').children('dd[lay-value="'+newVal+'"]').click();
                },
                category3 : function (newVal,oldVal) {
                    $('select[name="category3"]').next().find('.layui-anim').children('dd[lay-value="'+newVal+'"]').click();
                }
            }
        });

        (function (add_step1) {
            // 更新 lay-filter="test1" 所在容器内的全部表单状态
            form.render(null,'component-form-step-1');
            // 品牌
            form.on('select(brand_id)',function (ret) {
                add_step1.brand_id = ret.value;
            });

            // 产品类型
            var getIndexByCatId = function (id) {
                for(var k in this){
                    if(this[k]['id'] == id){
                        return k;
                    }
                }
                return false;
            };
            form.on('select(category1)', function(ret){
                var clear23 = function (category2HTML,category3HTML) {
                    add_step1.category2 = '';
                    add_step1.category3 = '';
                    $('select[name="category2"]').html(category2HTML);
                    $('select[name="category3"]').html(category3HTML);
                    form.render('select','component-form-step-1');
                };
                console.log(ret);
                var category2HTML = '<option value="">请选择二级分类</option>';
                var category3HTML = '<option value="">请选择三级分类</option>';
                add_step1.category1 = ret.value;
                if(!add_step1.category1){
                    // 清空2，3级
                    clear23(category2HTML,category3HTML);
                    add_step1.category1_name = '';
                    return false;
                }
                add_step1.category1_name = $(ret.elem).find('option[value='+ret.value+']').text();
                // 记录选中索引
                var i = getIndexByCatId.call(commParam['category'],ret.value);
                if(i === false){
                    return false;
                }
                $(ret.elem).attr('data-i',i);

                // 选择第一级分类，获取第二级分类
                var category2 = commParam['category'][i]['children'];
                for(var ii=0,l=category2.length;ii<l;ii++){
                    category2HTML+='<option value="'+category2[ii]['id']+'">'+category2[ii]['name']+'</option>';
                }
                clear23(category2HTML,category3HTML);
            });
            form.on('select(category2)', function(ret){
                var clear3 = function (category3HTML) {
                    add_step1.category3 = '';
                    $('select[name="category3"]').html(category3HTML);
                    form.render('select','component-form-step-1');
                };
                console.log(ret);
                var category3HTML = '<option value="">请选择三级分类</option>';
                add_step1.category2 = ret.value;
                if(!add_step1.category2){
                    // 清空3级
                    clear3(category3HTML);
                    add_step1.category2_name = '';
                    return false;
                }
                add_step1.category2_name = $(ret.elem).find('option[value='+ret.value+']').text();
                // 读取1级分类索引
                var i = $('#category1').attr('data-i');
                // 记录2级分类索引
                var ii = getIndexByCatId.call(commParam['category'][i]['children'],ret.value);
                if(ii === false){
                    return false;
                }
                $(ret.elem).attr('data-ii',ii);

                // 选择第二级分类，获取第三级分类
                var category2 = commParam['category'][i]['children'];
                var category3 = category2[ii]['children'];
                for(var iii=0,l=category3.length;iii<l;iii++){
                    category3HTML+='<option value="'+category3[iii]['id']+'">'+category3[iii]['name']+'</option>';
                }
                clear3(category3HTML);
            });
            form.on('select(category3)', function(ret){
                console.log(ret);
                add_step1.category3 = ret.value;
                if(!add_step1.category3){
                    add_step1.category3_name = '';
                }else{
                    add_step1.category3_name = $(ret.elem).find('option[value='+ret.value+']').text();
                }
            });

            // 产地支持
            form.on('switch(region_type)', function(ret){
                // console.log(ret);
                // layer.tips('开关checked：'+ (this.checked ? 'true' : 'false'), ret.othis)
                add_step1.region_type = this.checked ? '1' : '0';
            });

            // 是否扣减库存（0否, 1是）
            form.on('switch(is_deduction_inventory)', function(ret){
                add_step1.is_deduction_inventory = this.checked ? '1' : '0';
            });

            // 是否上架（下架后用户不可见, 0否, 1是）
            form.on('switch(is_shelves)', function(ret){
                add_step1.is_shelves = this.checked ? '1' : '0';
            });

            // 是否首页推荐（0否, 1是）
            form.on('switch(is_home_recommended)', function(ret){
                add_step1.is_home_recommended = this.checked ? '1' : '0';
            });

            // 是否已删除（0 未删除, 大于0则是删除时间）
            form.on('switch(is_delete_time)', function(ret){
                add_step1.is_delete_time = this.checked ? '1' : '0';
            });

            // add_step1表单提交 移动至 add.html 里面方便统一请求
            // form.on('submit(add_step1)', function(data){
            //     console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            //     console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
            //     console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            //     return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            // });

            // 封面图片
            var uploadImages = upload.render({
                elem: '#images' //绑定元素
                ,url: "{:get_url('/admin/file_commodity_photo/upload')}" //上传接口
                ,accept: 'images' //允许上传的文件类型
                // ,number: 5
                //,size: 50 //最大允许上传的文件大小
                // ,multiple: true // 多文件上传
                ,acceptMime: 'image/*'
                ,field:'image'
                ,done: function(res){
                    console.log(res);
                    if(res.code == 200){
                        add_step1.images = res.data;
                    }
                }
            });

            // 封面图片
            var uploadHomeRecommendedImages = upload.render({
                elem: '#home_recommended_images' //绑定元素
                ,url: "{:get_url('/admin/file_commodity_photo/upload')}" //上传接口
                ,accept: 'images' //允许上传的文件类型
                // ,number: 5
                //,size: 50 //最大允许上传的文件大小
                // ,multiple: true // 多文件上传
                ,acceptMime: 'image/*'
                ,field:'image'
                ,done: function(res){
                    console.log(res);
                    if(res.code == 200){
                        add_step1.home_recommended_images = res.data;
                    }
                }
            });

            // 批量上传文件
            var uploadInst = upload.render({
                elem: '#image-upload' //绑定元素
                ,url: "{:get_url('/admin/file_commodity_photo/upload')}" //上传接口
                ,accept: 'images' //允许上传的文件类型
                ,number: 5
                //,size: 50 //最大允许上传的文件大小
                ,multiple: true // 多文件上传
                ,acceptMime: 'image/*'
                ,field:'image'
                ,before: function () {
                    //add_step1.product_images = [];
                }
                ,allDone: function(obj){ //当文件全部被提交后，才触发
                    console.log(obj.total); //得到总文件数
                    console.log(obj.successful); //请求成功的文件数
                    console.log(obj.aborted); //请求失败的文件数
                }
                ,done: function(res){ //每个文件提交一次触发一次。详见“请求成功的回调”
                    if(res.code == 200){
                        // test http://img.fygift.com//2016/3/2396053567978906704.jpg
                        // $('#image-preview').append('<div class="layui-inline"><img src="'+res.data+'" width="200" height="200">' +
                        //     '<input type="hidden" name="product_images[]" value="'+res.data+'"></div>');
                        add_step1.product_images.push(res.data);

                        // 通知 add_step2
                        add_step2.productImagesChange(add_step1.product_images);
                    }
                    console.log(res);
                }
                ,error: function(){
                    //请求异常回调
                    console.log("error");
                }
            });
        })(add_step1);

        if(commParam['info'] !== null){
            // 编辑入参
            // add_step1.title = '测试商品';
            // add_step1.title_color = '#000000';
            // add_step1.inventory = '2';
            // add_step1.inventory_unit = '台';
            // add_step1.brand_id = '1';
            // add_step1.brand_name = '母婴用品-强生';
            // add_step1.category1 = '2';
            // // 等待300ms让category1渲染
            // setTimeout(function () {
            //     add_step1.category2 = '304';
            // },300);
            // // 等待300ms让category2渲染
            // setTimeout(function () {
            //     add_step1.category3 = '312';
            // },300);
            // add_step1.product_images = [
            //     'http://yanxuan.nosdn.127.net/0b8981ab0aec1589de1f4e665ee3a0a4.jpg',
            //     'http://yanxuan.nosdn.127.net/e09b2cceadb6b471339e6cb16a60408b.jpg',
            //     'http://yanxuan.nosdn.127.net/6a50e39b3cbd718bd435aa4c208dc5ad.jpg',
            //     'http://yanxuan.nosdn.127.net/ed9a103ee0f2f050837294277ab57645.jpg'
            // ];
            // add_step1.model = 'wy1263001';
            // add_step1.images = 'http://yanxuan.nosdn.127.net/00484fe6cf6e0ac917f8ee5023312fa2.png';
            // add_step1.original_price = '43.12';
            // add_step1.min_original_price = '43.12';
            // add_step1.max_original_price = '43.12';
            // add_step1.price = '49.00';
            // add_step1.min_price = '49.00';
            // add_step1.max_price = '49.00';
            // add_step1.give_integral = '1';
            // add_step1.buy_min_number = '1';
            // add_step1.buy_max_number = '5';
            // add_step1.photo_count = '3';
            // add_step1.attr_list = [{attrName:'测试属性名称',attrValue:'测试属性值'}];
            // add_step1.region_list = [];
            // add_step1.home_recommended_images = '';
            // add_step1.sales_count = '0';
            // add_step1.access_count = '0';
            // add_step1.video = '';
            // // 等待300ms让layui渲染
            // setTimeout(function () {
            //     add_step1.is_deduction_inventory = '1';
            //     add_step1.is_shelves = '1';
            //     add_step1.is_home_recommended = '0';
            //     add_step1.region_type = '1';
            //     add_step1.is_delete_time = '0';
            // },300);

            var param = commParam['info'];
            add_step1.title = param['title'];
            add_step1.title_color = param['title_color'];
            add_step1.inventory = param['inventory'];
            add_step1.inventory_unit = param['inventory_unit'];
            add_step1.brand_id = param['brand_id'];
            add_step1.brand_name = param['brand_name'];
            add_step1.category1 = param['category_tree'][0];
            // 等待300ms让category1渲染
            setTimeout(function () {
                add_step1.category2 = param['category_tree'][1];
            },300);
            // 等待300ms让category2渲染
            setTimeout(function () {
                add_step1.category3 = param['category_tree'][2];
            },300);
            add_step1.product_images = param['photo_list'];
            add_step1.model = param['model'];
            add_step1.images = param['images'];
            add_step1.original_price = param['original_price'];
            add_step1.min_original_price = param['min_original_price'];
            add_step1.max_original_price = param['max_original_price'];
            add_step1.price = param['price'];
            add_step1.min_price = param['min_price'];
            add_step1.max_price = param['max_price'];
            add_step1.give_integral = param['give_integral'];
            add_step1.buy_min_number = param['buy_min_number'];
            add_step1.buy_max_number = param['buy_max_number'];
            add_step1.photo_count = param['photo_count'];
            add_step1.attr_list = param['attr_list'];
            add_step1.region_list = param['region_list'];
            add_step1.home_recommended_images = param['home_recommended_images'];
            add_step1.sales_count = param['sales_count'];
            add_step1.access_count = param['access_count'];
            add_step1.video = param['video'];
            // 等待300ms让layui渲染
            setTimeout(function () {
                add_step1.is_deduction_inventory = param['is_deduction_inventory'];
                add_step1.is_shelves = param['is_shelves'];
                add_step1.is_home_recommended = param['is_home_recommended'];
                add_step1.region_type = param['region_type'];
                add_step1.is_delete_time = param['is_delete_time'];
            },300);
        }

        // 暴漏给外部
        window.add_step1 = add_step1;
    });
</script>